package com.xysoft.framework.mvc;

import java.util.Locale;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;

public class JacksonViewResolver implements ViewResolver {
	
	private View view;

	public void setView(View view) {
		this.view = view;
	}

	@Override
	public View resolveViewName(String viewName, Locale locale) throws Exception {
		if(!canHandle(viewName, locale)) return null;
		
		return view;
	}
	
	protected boolean canHandle(String viewName, Locale locale) {
		return StringUtils.startsWith(viewName, ViewConstants.JSON_VIEW_PREFIX);
	}

}
